package test;
import java.util.Scanner;
public class defead {
    static int k=0,count=0;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int m = scan.nextInt();
        boolean flag=false;
        for(int i=0;i<n;i++){
            int ad=scan.nextInt();
            k+=ad;
            if(k>=m){
                k=0;
                flag=true;
            }else{
                count++;
            }
        }
        if(flag){
            System.out.println(count);
        }else{
            System.out.println(-1);
        }
        scan.close();
    }
}
